{include file="public/header" /}
<span class="layui-breadcrumb">
  <a href="javascript:;">购买分类</a>
  <a><cite>列表</cite></a>
</span>
<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-body">
      <div style="color:#FF5722">网站购买分类</div>
      <div class="layui-form">
        <a class="layui-btn layui-btn-normal layui-btn-sm" target="_blank" href="{:url('Classpay/change')}?nav=classpay-classpaylist">添加</a>

        <div class="layui-form-item" style='margin-top:20px'>
          <div class="layui-inline">
            <label class="layui-form-label">开始时间</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" id="start_time" placeholder="yyyy-MM-dd" value="{$data_list['start_time']}">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">结束时间</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" id="end_time" placeholder="yyyy-MM-dd" value="{$data_list['end_time']}">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">分类名</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name='cname' placeholder="请输入分类名" value="{$data_list['cname']}">
            </div>
          </div>
          <div class="layui-inline">
            <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="sear()">查询</button>
            <a href="{:url('Classpay/index')}?nav=classpay-classpaylist" class="layui-btn layui-btn-sm layui-btn-danger">清空</a>
          </div>
        </div>

        <table class="layui-table" >
          <thead>
          <tr>
            <th>分类名</th>
            <th>URL</th>
            <th>排序</th>
            <th>发布时间</th>
            <th>状态</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          {volist name="data_list['list']" id="data"}
          <tr>
            <td>{$data.cname}</td>
            <td>{$data.url}</td>
            <td>{$data.seq}</td>
            <td>{$data.create_time}</td>
            <td>{eq name="$data.status" value="1"}正常{else/}已删除{/eq}</td>
            <td>
              {eq name="$data.status" value="1"}
              <button type="button" class="layui-btn layui-btn-danger layui-btn-xs" onclick="del({$data.id})">删除</button>
              <a target="_blank" href="{:url('Classpay/change')}?nav=classpay-classpaylist&id={$data.id}" class="layui-btn layui-btn-xs">编辑</a>
              {/eq}
            </td>
          </tr>
          {/volist}

          </tbody>
        </table>
        {$data_list['list']|raw}

      </div>

    </div>
  </div>
</div>

{include file="/public/footer" /}
<script>
  /*图片视频放大*/
  function show(url){
    layer.open({
      type: 2,
      title: false,
      area: ['60%', '50%'],
      shade: 0.8,
      closeBtn: 0,
      fixed: false,
      shadeClose: true,
      content: url
    });
  }

  function del(id){
    layer.confirm('你确定要删除吗', {
      btn: ['确定','取消'] //按钮
    }, function(){
      layer.load();
      $.post("{:url('Classpay/del')}",{id:id},function(res){
        if(res.status=='0'){
          layer.closeAll('loading');
          layer.msg(res.msg);
        }
        if(res.status=='1'){
          layer.msg(
                  res.msg,{icon: 1,time: 600},
                  function(){
                    layer.closeAll('loading');
                    location.href=location.href;
                  });
        }
      })
    });
  }

  //日期
  layui.use('laydate', function(){
    var laydate = layui.laydate;
    laydate.render({
      elem: '#start_time'
    });
    laydate.render({
      elem: '#end_time'
    });
  })
  /*查询*/
  function sear(){
    var start_time=$.trim($("#start_time").val());
    var end_time=$.trim($("#end_time").val());
    var cname=$.trim($("input[name='cname']").val());
    if(start_time=='' && end_time=='' && cname==''){
      layer.msg('请输入查询条件');
      return false;
    }

    window.location.href="{:url('Classpay/index')}"+"?nav=classpay-classpaylist&start_time="+start_time+"&end_time="+end_time+"&cname="+cname;
  }


</script>
